package com.blog.service.impl;

import com.blog.dao.BloggerDao;
import com.blog.entity.Blogger;
import com.blog.service.BloggerService;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("bloggerService")
public class BloggerServiceImpl implements BloggerService {
    @Resource
    private BloggerDao bloggerDao;

    public Blogger find() {
        return bloggerDao.find();
    }

    @Override
    public Blogger getUserById(int id) {
        return bloggerDao.getUserById(id);
    }

    public Blogger getByUserNumber(String userNumber) {
        return bloggerDao.getByUserNumber(userNumber);
    }

    public Integer update(Blogger blogger) {
        SecurityUtils.getSubject().getSession().setAttribute("currentUser", blogger);//更新的时候将当前登陆对象存进session
        return bloggerDao.update(blogger);
    }

    @Override
    public int addUser(Blogger blogger) {
        return bloggerDao.addUser(blogger);
    }

    @Override
    public List<Blogger> postBlogCountList() {
        return bloggerDao.postBlogCountList();
    }


}

